package classes.view.component 
{
	import classes.controller.DAOSendFlash;
	import classes.controller.DAOSendJS;
	import classes.controller.EDataObject;
	import classes.controller.ESendJS;
	import classes.model.VOIsLocal;
	
	import com.d4p.custom.customScrollBar.Scrollbar;
	import com.greensock.TweenMax;
	import com.greensock.easing.Cubic;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.TextField;
	
	public class PopupAlert extends Sprite
	{
		private var _btn1_mc:MovieClip;
		private var _btn2_mc:MovieClip;
		private var _text_text:TextField;
		
		private var _mode:int;
		public function PopupAlert() 
		{
			super();
			setLayOut();
			initListener();
			defaultSetting();
		}
		
		private function setLayOut():void
		{
			this._btn1_mc	=	this.getChildByName('btn1_mc') as MovieClip;
			this._btn2_mc	=	this.getChildByName('btn2_mc') as MovieClip;
			this._text_text = 	this.getChildByName('text_txt')	as TextField;
		}
		
		private function initListener():void
		{
			this._btn1_mc.addEventListener(MouseEvent.CLICK, 	btn1Click);
			this._btn2_mc.addEventListener(MouseEvent.CLICK,	btn2Click);
		}
		
		private function defaultSetting():void
		{
			
		}
		
		public function on($title:String, $btn1Txt:String, $btn2Txt:String, $mode:int):void
		{
			_mode = $mode;
			this._text_text.htmlText = $title;
			this._btn1_mc.text_txt.text = $btn1Txt;
			this._btn2_mc.text_txt.text = $btn2Txt;
		}
		
		private function btn1Click(e:MouseEvent):void 
		{
			if(_mode==0){
				//오답노트에서 왔을경우 
				//시작하기 
				dispatchEvent(new EDataObject(["startCorrectSingleMode"], EDataObject.EVENT_DATAOBJECT));
			}else{
				//설정하기 
				dispatchEvent(new EDataObject(["onMakeSinglePopup"], EDataObject.EVENT_DATAOBJECT));
			}
		}
		
		private function btn2Click(e:MouseEvent):void 
		{
			if(_mode==0){
				//오답노트에서 왔을경우 
				//닫기 
				ExternalInterface.call('selfClose');
			}else{
				//돌아가기 
				dispatchEvent(new EDataObject(["close"], EDataObject.EVENT_DATAOBJECT));
			}
			
			//this.dispatchEvent(new EDataObject(["close"], EDataObject.EVENT_DATAOBJECT));
		}
		
	}
}